/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Records.Database;

import Records.Attributes.getSongAttributes;
import java.util.ArrayList;
import java.util.HashMap;

/**
 *
 * @author Alexander Wilson
 */
public class DuplicateEntry {

    private static HashMap hm;
    private static ArrayList<String> valSet;

    public static ArrayList getValues(String Title, String Artist) {
        System.out.println("DuplicateEntry.getValues(" + Title + ", " + Artist + ")");

        if (!isDuplicate(Title, Artist)) {
            valSet = getSongAttributes.parseXml(Artist, Title, false);
        } else {
            valSet = null;
        }
        if (valSet != null) {
            String newTitle = valSet.get(0);
            String newArtist = valSet.get(1);
            getHm().put(newTitle + "," + newArtist, valSet);
        }
        return valSet;
    }

    public static boolean isDuplicate(String Title, String Artist) {
        System.out.println("DuplicateEntry.isDuplicate(" + Title + ", " + Artist + ")");
        if (getHm().containsKey(Title + "," + Artist)) {
            System.out.println("----Duplicate found----");
            return true;
        } else {
            System.out.println("----New Entry----");
            return false;
        }
    }

    /**
     * @return the hm
     */
    public static HashMap getHm() {
        return hm;
    }

    /**
     * @param aHm the hm to set
     */
    public static void setHm(HashMap aHm) {
        hm = aHm;
    }
}
